package com.hnucm.springboot.springboot.controller;

import com.hnucm.springboot.springboot.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
public class TestController {
    @RequestMapping("/test")
    public String test(Model model){
        List<User>  userList = new ArrayList<>();
        for (int i = 0 ; i < 10 ; i ++){
            User user = new User();
            user.setId(i);
            user.setName("张三"+i);
            user.setAge(20+i);
            userList.add(user);
        }

        model.addAttribute("userList",userList);
        model.addAttribute("name","张三");
        return "test.html";
    }

}
